﻿@model IEnumerable<ApplicationUser>

<br />
<div class="card shadow border-0 mt-4">
    <div class="card-header bg-success bg-gradient m-lg-0 py-3">
        <div class="row">
            <div class="col-12 text-center">
                <h2 class="text-white py-2">User List</h2>
            </div>
        </div>
    </div>
    <div class="card-body p-4">
        @if (Model.Count() > 0)
        {
            <table class="table table-bordered table-striped">
                <tr class="table-secondary">
                    <th>Email</th>
                    <th>Name</th>
                    <th>Roles</th>
                    <th>Claims</th>
                    <th></th>
                </tr>
                @foreach (var item in Model)
                {
                    <tr>
                        <td>@item.Email</td>
                        <td>@item.Name</td>
                        <td>@item.Role</td>
                        <td>@item.UserClaim</td>
                        <td style="width:450px;">
                            <div class="row">
                                <div class="col-3">
                                    <a asp-action="ManageRole" asp-for-userId="@item.Id" class="btn btn-primary w-100" style="course:pointer">
                                        Roles
                                    </a>
                                </div>
                                <div class="col-3">
                                    <a asp-action="ManageUserClaim" asp-for-userId="@item.Id" class="btn btn-info w-100" style="course:pointer">
                                        Claims
                                    </a>
                                </div>
                                <div class="col-3">
                                    @if (item.LockoutEnd == null || item.LockoutEnd < DateTime.Now)
                                    {
                                        <form asp-action="LockUnlock" asp-route-userId="@item.Id">
                                            <input type="submit" class="btn btn-success w-100" style="course:pointer" value="Lock" />
                                        </form>
                                    }
                                    else
                                    {
                                        <form asp-action="LockUnlock" asp-route-userId="@item.Id">
                                            <input type="submit" class="btn btn-warning w-100" style="course:pointer" value="UnLock" />
                                        </form>
                                    }
                                </div>
                                <div class="col-3">
                                    <form asp-action="DeleteUser" asp-route-userId="@item.Id">
                                        <button type="submit" onclick="return confirm('Are you sure you want to delete this user?')" class="btn btn-danger w-100">
                                            Delete
                                        </button>
                                    </form>
                                </div>
                            </div>
                        </td>
                    </tr>
                }
            </table>
        }
    </div>

</div>
